//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2024 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto-codegenerator.
// DO NOT EDIT.

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
@_spi(SotoInternal) import SotoCore

extension QLDB {
    // MARK: Enums

    public enum EncryptionStatus: String, CustomStringConvertible, Codable, Sendable, CodingKeyRepresentable {
        case enabled = "ENABLED"
        case kmsKeyInaccessible = "KMS_KEY_INACCESSIBLE"
        case updating = "UPDATING"
        public var description: String { return self.rawValue }
    }

    public enum ErrorCause: String, CustomStringConvertible, Codable, Sendable, CodingKeyRepresentable {
        case iamPermissionRevoked = "IAM_PERMISSION_REVOKED"
        case kinesisStreamNotFound = "KINESIS_STREAM_NOT_FOUND"
        public var description: String { return self.rawValue }
    }

    public enum ExportStatus: String, CustomStringConvertible, Codable, Sendable, CodingKeyRepresentable {
        case cancelled = "CANCELLED"
        case completed = "COMPLETED"
        case inProgress = "IN_PROGRESS"
        public var description: String { return self.rawValue }
    }

    public enum LedgerState: String, CustomStringConvertible, Codable, Sendable, CodingKeyRepresentable {
        case active = "ACTIVE"
        case creating = "CREATING"
        case deleted = "DELETED"
        case deleting = "DELETING"
        public var description: String { return self.rawValue }
    }

    public enum OutputFormat: String, CustomStringConvertible, Codable, Sendable, CodingKeyRepresentable {
        case ionBinary = "ION_BINARY"
        case ionText = "ION_TEXT"
        case json = "JSON"
        public var description: String { return self.rawValue }
    }

    public enum PermissionsMode: String, CustomStringConvertible, Codable, Sendable, CodingKeyRepresentable {
        case allowAll = "ALLOW_ALL"
        case standard = "STANDARD"
        public var description: String { return self.rawValue }
    }

    public enum S3ObjectEncryptionType: String, CustomStringConvertible, Codable, Sendable, CodingKeyRepresentable {
        case noEncryption = "NO_ENCRYPTION"
        case sseKms = "SSE_KMS"
        case sseS3 = "SSE_S3"
        public var description: String { return self.rawValue }
    }

    public enum StreamStatus: String, CustomStringConvertible, Codable, Sendable, CodingKeyRepresentable {
        case active = "ACTIVE"
        case canceled = "CANCELED"
        case completed = "COMPLETED"
        case failed = "FAILED"
        case impaired = "IMPAIRED"
        public var description: String { return self.rawValue }
    }

    // MARK: Shapes

    public struct CancelJournalKinesisStreamRequest: AWSEncodableShape {
        /// The name of the ledger.
        public let ledgerName: String
        /// The UUID (represented in Base62-encoded text) of the QLDB journal stream to be canceled.
        public let streamId: String

        @inlinable
        public init(ledgerName: String, streamId: String) {
            self.ledgerName = ledgerName
            self.streamId = streamId
        }

        public func encode(to encoder: Encoder) throws {
            let request = encoder.userInfo[.awsRequest]! as! RequestEncodingContainer
            _ = encoder.container(keyedBy: CodingKeys.self)
            request.encodePath(self.ledgerName, key: "LedgerName")
            request.encodePath(self.streamId, key: "StreamId")
        }

        public func validate(name: String) throws {
            try self.validate(self.ledgerName, name: "ledgerName", parent: name, max: 32)
            try self.validate(self.ledgerName, name: "ledgerName", parent: name, min: 1)
            try self.validate(self.ledgerName, name: "ledgerName", parent: name, pattern: "^(?!^.*--)(?!^[0-9]+$)(?!^-)(?!.*-$)^[A-Za-z0-9-]+$")
            try self.validate(self.streamId, name: "streamId", parent: name, max: 22)
            try self.validate(self.streamId, name: "streamId", parent: name, min: 22)
            try self.validate(self.streamId, name: "streamId", parent: name, pattern: "^[A-Za-z-0-9]+$")
        }

        private enum CodingKeys: CodingKey {}
    }

    public struct CancelJournalKinesisStreamResponse: AWSDecodableShape {
        /// The UUID (Base62-encoded text) of the canceled QLDB journal stream.
        public let streamId: String?

        @inlinable
        public init(streamId: String? = nil) {
            self.streamId = streamId
        }

        private enum CodingKeys: String, CodingKey {
            case streamId = "StreamId"
        }
    }

    public struct CreateLedgerRequest: AWSEncodableShape {
        /// Specifies whether the ledger is protected from being deleted by any user. If not defined during ledger creation, this feature is enabled (true) by default. If deletion protection is enabled, you must first disable it before you can delete the ledger. You can disable it by calling the UpdateLedger operation to set this parameter to false.
        public let deletionProtection: Bool?
        /// The key in Key Management Service (KMS) to use for encryption of data at rest in the ledger. For more information, see Encryption at rest in the Amazon QLDB Developer Guide. Use one of the following options to specify this parameter:    AWS_OWNED_KMS_KEY: Use an KMS key that is owned and managed by Amazon Web Services on your behalf.    Undefined: By default, use an Amazon Web Services owned KMS key.    A valid symmetric customer managed KMS key: Use the specified symmetric encryption KMS key in your account that you create, own, and manage. Amazon QLDB does not support asymmetric keys. For more information, see Using symmetric and asymmetric keys in the Key Management Service Developer Guide.   To specify a customer managed KMS key, you can use its key ID, Amazon Resource Name (ARN), alias name, or alias ARN. When using an alias name, prefix it with "alias/". To specify a key in a different Amazon Web Services account, you must use the key ARN or alias ARN. For example:   Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab    Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab    Alias name: alias/ExampleAlias    Alias ARN: arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias    For more information, see Key identifiers (KeyId) in the Key Management Service Developer Guide.
        public let kmsKey: String?
        /// The name of the ledger that you want to create. The name must be unique among all of the ledgers in your Amazon Web Services account in the current Region. Naming constraints for ledger names are defined in Quotas in Amazon QLDB in the Amazon QLDB Developer Guide.
        public let name: String
        /// The permissions mode to assign to the ledger that you want to create. This parameter can have one of the following values:    ALLOW_ALL: A legacy permissions mode that enables access control with API-level granularity for ledgers. This mode allows users who have the SendCommand API permission for this ledger to run all PartiQL commands (hence, ALLOW_ALL) on any tables in the specified ledger. This mode disregards any table-level or command-level IAM permissions policies that you create for the ledger.    STANDARD: (Recommended) A permissions mode that enables access control with finer granularity for ledgers, tables, and PartiQL commands. By default, this mode denies all user requests to run any PartiQL commands on any tables in this ledger. To allow PartiQL commands to run, you must create IAM permissions policies for specific table resources and PartiQL actions, in addition to the SendCommand API permission for the ledger. For information, see Getting started with the standard permissions mode in the Amazon QLDB Developer Guide.    We strongly recommend using the STANDARD permissions mode to maximize the security of your ledger data.
        public let permissionsMode: PermissionsMode
        /// The key-value pairs to add as tags to the ledger that you want to create. Tag keys are case sensitive. Tag values are case sensitive and can be null.
        public let tags: [String: String]?

        @inlinable
        public init(deletionProtection: Bool? = nil, kmsKey: String? = nil, name: String, permissionsMode: PermissionsMode, tags: [String: String]? = nil) {
            self.deletionProtection = deletionProtection
            self.kmsKey = kmsKey
            self.name = name
            self.permissionsMode = permissionsMode
            self.tags = tags
        }

        public func validate(name: String) throws {
            try self.validate(self.kmsKey, name: "kmsKey", parent: name, max: 1600)
            try self.validate(self.name, name: "name", parent: name, max: 32)
            try self.validate(self.name, name: "name", parent: name, min: 1)
            try self.validate(self.name, name: "name", parent: name, pattern: "^(?!^.*--)(?!^[0-9]+$)(?!^-)(?!.*-$)^[A-Za-z0-9-]+$")
            try self.tags?.forEach {
                try validate($0.key, name: "tags.key", parent: name, max: 128)
                try validate($0.key, name: "tags.key", parent: name, min: 1)
                try validate($0.value, name: "tags[\"\($0.key)\"]", parent: name, max: 256)
            }
            try self.validate(self.tags, name: "tags", parent: name, max: 200)
        }

        private enum CodingKeys: String, CodingKey {
            case deletionProtection = "DeletionProtection"
            case kmsKey = "KmsKey"
            case name = "Name"
            case permissionsMode = "PermissionsMode"
            case tags = "Tags"
        }
    }

    public struct CreateLedgerResponse: AWSDecodableShape {
        /// The Amazon Resource Name (ARN) for the ledger.
        public let arn: String?
        /// The date and time, in epoch time format, when the ledger was created. (Epoch time format is the number of seconds elapsed since 12:00:00 AM January 1, 1970 UTC.)
        public let creationDateTime: Date?
        /// Specifies whether the ledger is protected from being deleted by any user. If not defined during ledger creation, this feature is enabled (true) by default. If deletion protection is enabled, you must first disable it before you can delete the ledger. You can disable it by calling the UpdateLedger operation to set this parameter to false.
        public let deletionProtection: Bool?
        /// The ARN of the customer managed KMS key that the ledger uses for encryption at rest. If this parameter is undefined, the ledger uses an Amazon Web Services owned KMS key for encryption.
        public let kmsKeyArn: String?
        /// The name of the ledger.
        public let name: String?
        /// The permissions mode of the ledger that you created.
        public let permissionsMode: PermissionsMode?
        /// The current status of the ledger.
        public let state: LedgerState?

        @inlinable
        public init(arn: String? = nil, creationDateTime: Date? = nil, deletionProtection: Bool? = nil, kmsKeyArn: String? = nil, name: String? = nil, permissionsMode: PermissionsMode? = nil, state: LedgerState? = nil) {
            self.arn = arn
            self.creationDateTime = creationDateTime
            self.deletionProtection = deletionProtection
            self.kmsKeyArn = kmsKeyArn
            self.name = name
            self.permissionsMode = permissionsMode
            self.state = state
        }

        private enum CodingKeys: String, CodingKey {
            case arn = "Arn"
            case creationDateTime = "CreationDateTime"
            case deletionProtection = "DeletionProtection"
            case kmsKeyArn = "KmsKeyArn"
            case name = "Name"
            case permissionsMode = "PermissionsMode"
            case state = "State"
        }
    }

    public struct DeleteLedgerRequest: AWSEncodableShape {
        /// The name of the ledger that you want to delete.
        public let name: String

        @inlinable
        public init(name: String) {
            self.name = name
        }

        public func encode(to encoder: Encoder) throws {
            let request = encoder.userInfo[.awsRequest]! as! RequestEncodingContainer
            _ = encoder.container(keyedBy: CodingKeys.self)
            request.encodePath(self.name, key: "Name")
        }

        public func validate(name: String) throws {
            try self.validate(self.name, name: "name", parent: name, max: 32)
            try self.validate(self.name, name: "name", parent: name, min: 1)
            try self.validate(self.name, name: "name", parent: name, pattern: "^(?!^.*--)(?!^[0-9]+$)(?!^-)(?!.*-$)^[A-Za-z0-9-]+$")
        }

        private enum CodingKeys: CodingKey {}
    }

    public struct DescribeJournalKinesisStreamRequest: AWSEncodableShape {
        /// The name of the ledger.
        public let ledgerName: String
        /// The UUID (represented in Base62-encoded text) of the QLDB journal stream to describe.
        public let streamId: String

        @inlinable
        public init(ledgerName: String, streamId: String) {
            self.ledgerName = ledgerName
            self.streamId = streamId
        }

        public func encode(to encoder: Encoder) throws {
            let request = encoder.userInfo[.awsRequest]! as! RequestEncodingContainer
            _ = encoder.container(keyedBy: CodingKeys.self)
            request.encodePath(self.ledgerName, key: "LedgerName")
            request.encodePath(self.streamId, key: "StreamId")
        }

        public func validate(name: String) throws {
            try self.validate(self.ledgerName, name: "ledgerName", parent: name, max: 32)
            try self.validate(self.ledgerName, name: "ledgerName", parent: name, min: 1)
            try self.validate(self.ledgerName, name: "ledgerName", parent: name, pattern: "^(?!^.*--)(?!^[0-9]+$)(?!^-)(?!.*-$)^[A-Za-z0-9-]+$")
            try self.validate(self.streamId, name: "streamId", parent: name, max: 22)
            try self.validate(self.streamId, name: "streamId", parent: name, min: 22)
            try self.validate(self.streamId, name: "streamId", parent: name, pattern: "^[A-Za-z-0-9]+$")
        }

        private enum CodingKeys: CodingKey {}
    }

    public struct DescribeJournalKinesisStreamResponse: AWSDecodableShape {
        /// Information about the QLDB journal stream returned by a DescribeJournalS3Export request.
        public let stream: JournalKinesisStreamDescription?

        @inlinable
        public init(stream: JournalKinesisStreamDescription? = nil) {
            self.stream = stream
        }

        private enum CodingKeys: String, CodingKey {
            case stream = "Stream"
        }
    }

    public struct DescribeJournalS3ExportRequest: AWSEncodableShape {
        /// The UUID (represented in Base62-encoded text) of the journal export job to describe.
        public let exportId: String
        /// The name of the ledger.
        public let name: String

        @inlinable
        public init(exportId: String, name: String) {
            self.exportId = exportId
            self.name = name
        }

        public func encode(to encoder: Encoder) throws {
            let request = encoder.userInfo[.awsRequest]! as! RequestEncodingContainer
            _ = encoder.container(keyedBy: CodingKeys.self)
            request.encodePath(self.exportId, key: "ExportId")
            request.encodePath(self.name, key: "Name")
        }

        public func validate(name: String) throws {
            try self.validate(self.exportId, name: "exportId", parent: name, max: 22)
            try self.validate(self.exportId, name: "exportId", parent: name, min: 22)
            try self.validate(self.exportId, name: "exportId", parent: name, pattern: "^[A-Za-z-0-9]+$")
            try self.validate(self.name, name: "name", parent: name, max: 32)
            try self.validate(self.name, name: "name", parent: name, min: 1)
            try self.validate(self.name, name: "name", parent: name, pattern: "^(?!^.*--)(?!^[0-9]+$)(?!^-)(?!.*-$)^[A-Za-z0-9-]+$")
        }

        private enum CodingKeys: CodingKey {}
    }

    public struct DescribeJournalS3ExportResponse: AWSDecodableShape {
        /// Information about the journal export job returned by a DescribeJournalS3Export request.
        public let exportDescription: JournalS3ExportDescription

        @inlinable
        public init(exportDescription: JournalS3ExportDescription) {
            self.exportDescription = exportDescription
        }

        private enum CodingKeys: String, CodingKey {
            case exportDescription = "ExportDescription"
        }
    }

    public struct DescribeLedgerRequest: AWSEncodableShape {
        /// The name of the ledger that you want to describe.
        public let name: String

        @inlinable
        public init(name: String) {
            self.name = name
        }

        public func encode(to encoder: Encoder) throws {
            let request = encoder.userInfo[.awsRequest]! as! RequestEncodingContainer
            _ = encoder.container(keyedBy: CodingKeys.self)
            request.encodePath(self.name, key: "Name")
        }

        public func validate(name: String) throws {
            try self.validate(self.name, name: "name", parent: name, max: 32)
            try self.validate(self.name, name: "name", parent: name, min: 1)
            try self.validate(self.name, name: "name", parent: name, pattern: "^(?!^.*--)(?!^[0-9]+$)(?!^-)(?!.*-$)^[A-Za-z0-9-]+$")
        }

        private enum CodingKeys: CodingKey {}
    }

    public struct DescribeLedgerResponse: AWSDecodableShape {
        /// The Amazon Resource Name (ARN) for the ledger.
        public let arn: String?
        /// The date and time, in epoch time format, when the ledger was created. (Epoch time format is the number of seconds elapsed since 12:00:00 AM January 1, 1970 UTC.)
        public let creationDateTime: Date?
        /// Specifies whether the ledger is protected from being deleted by any user. If not defined during ledger creation, this feature is enabled (true) by default. If deletion protection is enabled, you must first disable it before you can delete the ledger. You can disable it by calling the UpdateLedger operation to set this parameter to false.
        public let deletionProtection: Bool?
        /// Information about the encryption of data at rest in the ledger. This includes the current status, the KMS key, and when the key became inaccessible (in the case of an error). If this parameter is undefined, the ledger uses an Amazon Web Services owned KMS key for encryption.
        public let encryptionDescription: LedgerEncryptionDescription?
        /// The name of the ledger.
        public let name: String?
        /// The permissions mode of the ledger.
        public let permissionsMode: PermissionsMode?
        /// The current status of the ledger.
        public let state: LedgerState?

        @inlinable
        public init(arn: String? = nil, creationDateTime: Date? = nil, deletionProtection: Bool? = nil, encryptionDescription: LedgerEncryptionDescription? = nil, name: String? = nil, permissionsMode: PermissionsMode? = nil, state: LedgerState? = nil) {
            self.arn = arn
            self.creationDateTime = creationDateTime
            self.deletionProtection = deletionProtection
            self.encryptionDescription = encryptionDescription
            self.name = name
            self.permissionsMode = permissionsMode
            self.state = state
        }

        private enum CodingKeys: String, CodingKey {
            case arn = "Arn"
            case creationDateTime = "CreationDateTime"
            case deletionProtection = "DeletionProtection"
            case encryptionDescription = "EncryptionDescription"
            case name = "Name"
            case permissionsMode = "PermissionsMode"
            case state = "State"
        }
    }

    public struct ExportJournalToS3Request: AWSEncodableShape {
        /// The exclusive end date and time for the range of journal contents to export. The ExclusiveEndTime must be in ISO 8601 date and time format and in Universal Coordinated Time (UTC). For example: 2019-06-13T21:36:34Z. The ExclusiveEndTime must be less than or equal to the current UTC date and time.
        public let exclusiveEndTime: Date
        /// The inclusive start date and time for the range of journal contents to export. The InclusiveStartTime must be in ISO 8601 date and time format and in Universal Coordinated Time (UTC). For example: 2019-06-13T21:36:34Z. The InclusiveStartTime must be before ExclusiveEndTime. If you provide an InclusiveStartTime that is before the ledger's CreationDateTime, Amazon QLDB defaults it to the ledger's CreationDateTime.
        public let inclusiveStartTime: Date
        /// The name of the ledger.
        public let name: String
        /// The output format of your exported journal data. A journal export job can write the data objects in either the text or binary representation of Amazon Ion format, or in JSON Lines text format. Default: ION_TEXT  In JSON Lines format, each journal block in an exported data object is a valid JSON object that is delimited by a newline. You can use this format to directly integrate JSON exports with analytics tools such as Amazon Athena and Glue because these services can parse newline-delimited JSON automatically.
        public let outputFormat: OutputFormat?
        /// The Amazon Resource Name (ARN) of the IAM role that grants QLDB permissions for a journal export job to do the following:   Write objects into your Amazon S3 bucket.   (Optional) Use your customer managed key in Key Management Service (KMS) for server-side encryption of your exported data.   To pass a role to QLDB when requesting a journal export, you must have permissions to perform the iam:PassRole action on the IAM role resource. This is required for all journal export requests.
        public let roleArn: String
        /// The configuration settings of the Amazon S3 bucket destination for your export request.
        public let s3ExportConfiguration: S3ExportConfiguration

        @inlinable
        public init(exclusiveEndTime: Date, inclusiveStartTime: Date, name: String, outputFormat: OutputFormat? = nil, roleArn: String, s3ExportConfiguration: S3ExportConfiguration) {
            self.exclusiveEndTime = exclusiveEndTime
            self.inclusiveStartTime = inclusiveStartTime
            self.name = name
            self.outputFormat = outputFormat
            self.roleArn = roleArn
            self.s3ExportConfiguration = s3ExportConfiguration
        }

        public func encode(to encoder: Encoder) throws {
            let request = encoder.userInfo[.awsRequest]! as! RequestEncodingContainer
            var container = encoder.container(keyedBy: CodingKeys.self)
            try container.encode(self.exclusiveEndTime, forKey: .exclusiveEndTime)
            try container.encode(self.inclusiveStartTime, forKey: .inclusiveStartTime)
            request.encodePath(self.name, key: "Name")
            try container.encodeIfPresent(self.outputFormat, forKey: .outputFormat)
            try container.encode(self.roleArn, forKey: .roleArn)
            try container.encode(self.s3ExportConfiguration, forKey: .s3ExportConfiguration)
        }

        public func validate(name: String) throws {
            try self.validate(self.name, name: "name", parent: name, max: 32)
            try self.validate(self.name, name: "name", parent: name, min: 1)
            try self.validate(self.name, name: "name", parent: name, pattern: "^(?!^.*--)(?!^[0-9]+$)(?!^-)(?!.*-$)^[A-Za-z0-9-]+$")
            try self.validate(self.roleArn, name: "roleArn", parent: name, max: 1600)
            try self.validate(self.roleArn, name: "roleArn", parent: name, min: 20)
            try self.s3ExportConfiguration.validate(name: "\(name).s3ExportConfiguration")
        }

        private enum CodingKeys: String, CodingKey {
            case exclusiveEndTime = "ExclusiveEndTime"
            case inclusiveStartTime = "InclusiveStartTime"
            case outputFormat = "OutputFormat"
            case roleArn = "RoleArn"
            case s3ExportConfiguration = "S3ExportConfiguration"
        }
    }

    public struct ExportJournalToS3Response: AWSDecodableShape {
        /// The UUID (represented in Base62-encoded text) that QLDB assigns to each journal export job. To describe your export request and check the status of the job, you can use ExportId to call DescribeJournalS3Export.
        public let exportId: String

        @inlinable
        public init(exportId: String) {
            self.exportId = exportId
        }

        private enum CodingKeys: String, CodingKey {
            case exportId = "ExportId"
        }
    }

    public struct GetBlockRequest: AWSEncodableShape {
        /// The location of the block that you want to request. An address is an Amazon Ion structure that has two fields: strandId and sequenceNo. For example: {strandId:"BlFTjlSXze9BIh1KOszcE3",sequenceNo:14}.
        public let blockAddress: ValueHolder
        /// The latest block location covered by the digest for which to request a proof. An address is an Amazon Ion structure that has two fields: strandId and sequenceNo. For example: {strandId:"BlFTjlSXze9BIh1KOszcE3",sequenceNo:49}.
        public let digestTipAddress: ValueHolder?
        /// The name of the ledger.
        public let name: String

        @inlinable
        public init(blockAddress: ValueHolder, digestTipAddress: ValueHolder? = nil, name: String) {
            self.blockAddress = blockAddress
            self.digestTipAddress = digestTipAddress
            self.name = name
        }

        public func encode(to encoder: Encoder) throws {
            let request = encoder.userInfo[.awsRequest]! as! RequestEncodingContainer
            var container = encoder.container(keyedBy: CodingKeys.self)
            try container.encode(self.blockAddress, forKey: .blockAddress)
            try container.encodeIfPresent(self.digestTipAddress, forKey: .digestTipAddress)
            request.encodePath(self.name, key: "Name")
        }

        public func validate(name: String) throws {
            try self.blockAddress.validate(name: "\(name).blockAddress")
            try self.digestTipAddress?.validate(name: "\(name).digestTipAddress")
            try self.validate(self.name, name: "name", parent: name, max: 32)
            try self.validate(self.name, name: "name", parent: name, min: 1)
            try self.validate(self.name, name: "name", parent: name, pattern: "^(?!^.*--)(?!^[0-9]+$)(?!^-)(?!.*-$)^[A-Za-z0-9-]+$")
        }

        private enum CodingKeys: String, CodingKey {
            case blockAddress = "BlockAddress"
            case digestTipAddress = "DigestTipAddress"
        }
    }

    public struct GetBlockResponse: AWSDecodableShape {
        /// The block data object in Amazon Ion format.
        public let block: ValueHolder
        /// The proof object in Amazon Ion format returned by a GetBlock request. A proof contains the list of hash values required to recalculate the specified digest using a Merkle tree, starting with the specified block.
        public let proof: ValueHolder?

        @inlinable
        public init(block: ValueHolder, proof: ValueHolder? = nil) {
            self.block = block
            self.proof = proof
        }

        private enum CodingKeys: String, CodingKey {
            case block = "Block"
            case proof = "Proof"
        }
    }

    public struct GetDigestRequest: AWSEncodableShape {
        /// The name of the ledger.
        public let name: String

        @inlinable
        public init(name: String) {
            self.name = name
        }

        public func encode(to encoder: Encoder) throws {
            let request = encoder.userInfo[.awsRequest]! as! RequestEncodingContainer
            _ = encoder.container(keyedBy: CodingKeys.self)
            request.encodePath(self.name, key: "Name")
        }

        public func validate(name: String) throws {
            try self.validate(self.name, name: "name", parent: name, max: 32)
            try self.validate(self.name, name: "name", parent: name, min: 1)
            try self.validate(self.name, name: "name", parent: name, pattern: "^(?!^.*--)(?!^[0-9]+$)(?!^-)(?!.*-$)^[A-Za-z0-9-]+$")
        }

        private enum CodingKeys: CodingKey {}
    }

    public struct GetDigestResponse: AWSDecodableShape {
        /// The 256-bit hash value representing the digest returned by a GetDigest request.
        public let digest: AWSBase64Data
        /// The latest block location covered by the digest that you requested. An address is an Amazon Ion structure that has two fields: strandId and sequenceNo.
        public let digestTipAddress: ValueHolder

        @inlinable
        public init(digest: AWSBase64Data, digestTipAddress: ValueHolder) {
            self.digest = digest
            self.digestTipAddress = digestTipAddress
        }

        private enum CodingKeys: String, CodingKey {
            case digest = "Digest"
            case digestTipAddress = "DigestTipAddress"
        }
    }

    public struct GetRevisionRequest: AWSEncodableShape {
        /// The block location of the document revision to be verified. An address is an Amazon Ion structure that has two fields: strandId and sequenceNo. For example: {strandId:"BlFTjlSXze9BIh1KOszcE3",sequenceNo:14}.
        public let blockAddress: ValueHolder
        /// The latest block location covered by the digest for which to request a proof. An address is an Amazon Ion structure that has two fields: strandId and sequenceNo. For example: {strandId:"BlFTjlSXze9BIh1KOszcE3",sequenceNo:49}.
        public let digestTipAddress: ValueHolder?
        /// The UUID (represented in Base62-encoded text) of the document to be verified.
        public let documentId: String
        /// The name of the ledger.
        public let name: String

        @inlinable
        public init(blockAddress: ValueHolder, digestTipAddress: ValueHolder? = nil, documentId: String, name: String) {
            self.blockAddress = blockAddress
            self.digestTipAddress = digestTipAddress
            self.documentId = documentId
            self.name = name
        }

        public func encode(to encoder: Encoder) throws {
            let request = encoder.userInfo[.awsRequest]! as! RequestEncodingContainer
            var container = encoder.container(keyedBy: CodingKeys.self)
            try container.encode(self.blockAddress, forKey: .blockAddress)
            try container.encodeIfPresent(self.digestTipAddress, forKey: .digestTipAddress)
            try container.encode(self.documentId, forKey: .documentId)
            request.encodePath(self.name, key: "Name")
        }

        public func validate(name: String) throws {
            try self.blockAddress.validate(name: "\(name).blockAddress")
            try self.digestTipAddress?.validate(name: "\(name).digestTipAddress")
            try self.validate(self.documentId, name: "documentId", parent: name, max: 22)
            try self.validate(self.documentId, name: "documentId", parent: name, min: 22)
            try self.validate(self.documentId, name: "documentId", parent: name, pattern: "^[A-Za-z-0-9]+$")
            try self.validate(self.name, name: "name", parent: name, max: 32)
            try self.validate(self.name, name: "name", parent: name, min: 1)
            try self.validate(self.name, name: "name", parent: name, pattern: "^(?!^.*--)(?!^[0-9]+$)(?!^-)(?!.*-$)^[A-Za-z0-9-]+$")
        }

        private enum CodingKeys: String, CodingKey {
            case blockAddress = "BlockAddress"
            case digestTipAddress = "DigestTipAddress"
            case documentId = "DocumentId"
        }
    }

    public struct GetRevisionResponse: AWSDecodableShape {
        /// The proof object in Amazon Ion format returned by a GetRevision request. A proof contains the list of hash values that are required to recalculate the specified digest using a Merkle tree, starting with the specified document revision.
        public let proof: ValueHolder?
        /// The document revision data object in Amazon Ion format.
        public let revision: ValueHolder

        @inlinable
        public init(proof: ValueHolder? = nil, revision: ValueHolder) {
            self.proof = proof
            self.revision = revision
        }

        private enum CodingKeys: String, CodingKey {
            case proof = "Proof"
            case revision = "Revision"
        }
    }

    public struct InvalidParameterException: AWSErrorShape {
        public let message: String?
        /// The name of the invalid parameter.
        public let parameterName: String?

        @inlinable
        public init(message: String? = nil, parameterName: String? = nil) {
            self.message = message
            self.parameterName = parameterName
        }

        private enum CodingKeys: String, CodingKey {
            case message = "Message"
            case parameterName = "ParameterName"
        }
    }

    public struct JournalKinesisStreamDescription: AWSDecodableShape {
        /// The Amazon Resource Name (ARN) of the QLDB journal stream.
        public let arn: String?
        /// The date and time, in epoch time format, when the QLDB journal stream was created. (Epoch time format is the number of seconds elapsed since 12:00:00 AM January 1, 1970 UTC.)
        public let creationTime: Date?
        /// The error message that describes the reason that a stream has a status of IMPAIRED or FAILED. This is not applicable to streams that have other status values.
        public let errorCause: ErrorCause?
        /// The exclusive date and time that specifies when the stream ends. If this parameter is undefined, the stream runs indefinitely until you cancel it.
        public let exclusiveEndTime: Date?
        /// The inclusive start date and time from which to start streaming journal data.
        public let inclusiveStartTime: Date?
        /// The configuration settings of the Amazon Kinesis Data Streams destination for a QLDB journal stream.
        public let kinesisConfiguration: KinesisConfiguration
        /// The name of the ledger.
        public let ledgerName: String
        /// The Amazon Resource Name (ARN) of the IAM role that grants QLDB permissions for a journal stream to write data records to a Kinesis Data Streams resource.
        public let roleArn: String
        /// The current state of the QLDB journal stream.
        public let status: StreamStatus
        /// The UUID (represented in Base62-encoded text) of the QLDB journal stream.
        public let streamId: String
        /// The user-defined name of the QLDB journal stream.
        public let streamName: String

        @inlinable
        public init(arn: String? = nil, creationTime: Date? = nil, errorCause: ErrorCause? = nil, exclusiveEndTime: Date? = nil, inclusiveStartTime: Date? = nil, kinesisConfiguration: KinesisConfiguration, ledgerName: String, roleArn: String, status: StreamStatus, streamId: String, streamName: String) {
            self.arn = arn
            self.creationTime = creationTime
            self.errorCause = errorCause
            self.exclusiveEndTime = exclusiveEndTime
            self.inclusiveStartTime = inclusiveStartTime
            self.kinesisConfiguration = kinesisConfiguration
            self.ledgerName = ledgerName
            self.roleArn = roleArn
            self.status = status
            self.streamId = streamId
            self.streamName = streamName
        }

        private enum CodingKeys: String, CodingKey {
            case arn = "Arn"
            case creationTime = "CreationTime"
            case errorCause = "ErrorCause"
            case exclusiveEndTime = "ExclusiveEndTime"
            case inclusiveStartTime = "InclusiveStartTime"
            case kinesisConfiguration = "KinesisConfiguration"
            case ledgerName = "LedgerName"
            case roleArn = "RoleArn"
            case status = "Status"
            case streamId = "StreamId"
            case streamName = "StreamName"
        }
    }

    public struct JournalS3ExportDescription: AWSDecodableShape {
        /// The exclusive end date and time for the range of journal contents that was specified in the original export request.
        public let exclusiveEndTime: Date
        /// The date and time, in epoch time format, when the export job was created. (Epoch time format is the number of seconds elapsed since 12:00:00 AM January 1, 1970 UTC.)
        public let exportCreationTime: Date
        /// The UUID (represented in Base62-encoded text) of the journal export job.
        public let exportId: String
        /// The inclusive start date and time for the range of journal contents that was specified in the original export request.
        public let inclusiveStartTime: Date
        /// The name of the ledger.
        public let ledgerName: String
        /// The output format of the exported journal data.
        public let outputFormat: OutputFormat?
        /// The Amazon Resource Name (ARN) of the IAM role that grants QLDB permissions for a journal export job to do the following:   Write objects into your Amazon Simple Storage Service (Amazon S3) bucket.   (Optional) Use your customer managed key in Key Management Service (KMS) for server-side encryption of your exported data.
        public let roleArn: String
        public let s3ExportConfiguration: S3ExportConfiguration
        /// The current state of the journal export job.
        public let status: ExportStatus

        @inlinable
        public init(exclusiveEndTime: Date, exportCreationTime: Date, exportId: String, inclusiveStartTime: Date, ledgerName: String, outputFormat: OutputFormat? = nil, roleArn: String, s3ExportConfiguration: S3ExportConfiguration, status: ExportStatus) {
            self.exclusiveEndTime = exclusiveEndTime
            self.exportCreationTime = exportCreationTime
            self.exportId = exportId
            self.inclusiveStartTime = inclusiveStartTime
            self.ledgerName = ledgerName
            self.outputFormat = outputFormat
            self.roleArn = roleArn
            self.s3ExportConfiguration = s3ExportConfiguration
            self.status = status
        }

        private enum CodingKeys: String, CodingKey {
            case exclusiveEndTime = "ExclusiveEndTime"
            case exportCreationTime = "ExportCreationTime"
            case exportId = "ExportId"
            case inclusiveStartTime = "InclusiveStartTime"
            case ledgerName = "LedgerName"
            case outputFormat = "OutputFormat"
            case roleArn = "RoleArn"
            case s3ExportConfiguration = "S3ExportConfiguration"
            case status = "Status"
        }
    }

    public struct KinesisConfiguration: AWSEncodableShape & AWSDecodableShape {
        /// Enables QLDB to publish multiple data records in a single Kinesis Data Streams record, increasing the number of records sent per API call. Default: True   Record aggregation has important implications for processing records and requires de-aggregation in your stream consumer. To learn more, see KPL Key Concepts and Consumer De-aggregation in the Amazon Kinesis Data Streams Developer Guide.
        public let aggregationEnabled: Bool?
        /// The Amazon Resource Name (ARN) of the Kinesis Data Streams resource.
        public let streamArn: String

        @inlinable
        public init(aggregationEnabled: Bool? = nil, streamArn: String) {
            self.aggregationEnabled = aggregationEnabled
            self.streamArn = streamArn
        }

        public func validate(name: String) throws {
            try self.validate(self.streamArn, name: "streamArn", parent: name, max: 1600)
            try self.validate(self.streamArn, name: "streamArn", parent: name, min: 20)
        }

        private enum CodingKeys: String, CodingKey {
            case aggregationEnabled = "AggregationEnabled"
            case streamArn = "StreamArn"
        }
    }

    public struct LedgerEncryptionDescription: AWSDecodableShape {
        /// The current state of encryption at rest for the ledger. This can be one of the following values:    ENABLED: Encryption is fully enabled using the specified key.    UPDATING: The ledger is actively processing the specified key change. Key changes in QLDB are asynchronous. The ledger is fully accessible without any performance impact while the key change is being processed. The amount of time it takes to update a key varies depending on the ledger size.    KMS_KEY_INACCESSIBLE: The specified customer managed KMS key is not accessible, and the ledger is impaired. Either the key was disabled or deleted, or the grants on the key were revoked. When a ledger is impaired, it is not accessible and does not accept any read or write requests. An impaired ledger automatically returns to an active state after you restore the grants on the key, or re-enable the key that was disabled. However, deleting a customer managed KMS key is irreversible. After a key is deleted, you can no longer access the ledgers that are protected with that key, and the data becomes unrecoverable permanently.
        public let encryptionStatus: EncryptionStatus
        /// The date and time, in epoch time format, when the KMS key first became inaccessible, in the case of an error. (Epoch time format is the number of seconds that have elapsed since 12:00:00 AM January 1, 1970 UTC.) This parameter is undefined if the KMS key is accessible.
        public let inaccessibleKmsKeyDateTime: Date?
        /// The Amazon Resource Name (ARN) of the customer managed KMS key that the ledger uses for encryption at rest. If this parameter is undefined, the ledger uses an Amazon Web Services owned KMS key for encryption. It will display AWS_OWNED_KMS_KEY when updating the ledger's encryption configuration to the Amazon Web Services owned KMS key.
        public let kmsKeyArn: String

        @inlinable
        public init(encryptionStatus: EncryptionStatus, inaccessibleKmsKeyDateTime: Date? = nil, kmsKeyArn: String) {
            self.encryptionStatus = encryptionStatus
            self.inaccessibleKmsKeyDateTime = inaccessibleKmsKeyDateTime
            self.kmsKeyArn = kmsKeyArn
        }

        private enum CodingKeys: String, CodingKey {
            case encryptionStatus = "EncryptionStatus"
            case inaccessibleKmsKeyDateTime = "InaccessibleKmsKeyDateTime"
            case kmsKeyArn = "KmsKeyArn"
        }
    }

    public struct LedgerSummary: AWSDecodableShape {
        /// The date and time, in epoch time format, when the ledger was created. (Epoch time format is the number of seconds elapsed since 12:00:00 AM January 1, 1970 UTC.)
        public let creationDateTime: Date?
        /// The name of the ledger.
        public let name: String?
        /// The current status of the ledger.
        public let state: LedgerState?

        @inlinable
        public init(creationDateTime: Date? = nil, name: String? = nil, state: LedgerState? = nil) {
            self.creationDateTime = creationDateTime
            self.name = name
            self.state = state
        }

        private enum CodingKeys: String, CodingKey {
            case creationDateTime = "CreationDateTime"
            case name = "Name"
            case state = "State"
        }
    }

    public struct LimitExceededException: AWSErrorShape {
        public let message: String?
        /// The type of resource.
        public let resourceType: String?

        @inlinable
        public init(message: String? = nil, resourceType: String? = nil) {
            self.message = message
            self.resourceType = resourceType
        }

        private enum CodingKeys: String, CodingKey {
            case message = "Message"
            case resourceType = "ResourceType"
        }
    }

    public struct ListJournalKinesisStreamsForLedgerRequest: AWSEncodableShape {
        /// The name of the ledger.
        public let ledgerName: String
        /// The maximum number of results to return in a single ListJournalKinesisStreamsForLedger request. (The actual number of results returned might be fewer.)
        public let maxResults: Int?
        /// A pagination token, indicating that you want to retrieve the next page of results. If you received a value for NextToken in the response from a previous ListJournalKinesisStreamsForLedger call, you should use that value as input here.
        public let nextToken: String?

        @inlinable
        public init(ledgerName: String, maxResults: Int? = nil, nextToken: String? = nil) {
            self.ledgerName = ledgerName
            self.maxResults = maxResults
            self.nextToken = nextToken
        }

        public func encode(to encoder: Encoder) throws {
            let request = encoder.userInfo[.awsRequest]! as! RequestEncodingContainer
            _ = encoder.container(keyedBy: CodingKeys.self)
            request.encodePath(self.ledgerName, key: "LedgerName")
            request.encodeQuery(self.maxResults, key: "max_results")
            request.encodeQuery(self.nextToken, key: "next_token")
        }

        public func validate(name: String) throws {
            try self.validate(self.ledgerName, name: "ledgerName", parent: name, max: 32)
            try self.validate(self.ledgerName, name: "ledgerName", parent: name, min: 1)
            try self.validate(self.ledgerName, name: "ledgerName", parent: name, pattern: "^(?!^.*--)(?!^[0-9]+$)(?!^-)(?!.*-$)^[A-Za-z0-9-]+$")
            try self.validate(self.maxResults, name: "maxResults", parent: name, max: 100)
            try self.validate(self.maxResults, name: "maxResults", parent: name, min: 1)
            try self.validate(self.nextToken, name: "nextToken", parent: name, max: 1024)
            try self.validate(self.nextToken, name: "nextToken", parent: name, min: 4)
            try self.validate(self.nextToken, name: "nextToken", parent: name, pattern: "^[A-Za-z-0-9+/=]+$")
        }

        private enum CodingKeys: CodingKey {}
    }

    public struct ListJournalKinesisStreamsForLedgerResponse: AWSDecodableShape {
        ///   If NextToken is empty, the last page of results has been processed and there are no more results to be retrieved.   If NextToken is not empty, more results are available. To retrieve the next page of results, use the value of NextToken in a subsequent ListJournalKinesisStreamsForLedger call.
        public let nextToken: String?
        /// The QLDB journal streams that are currently associated with the given ledger.
        public let streams: [JournalKinesisStreamDescription]?

        @inlinable
        public init(nextToken: String? = nil, streams: [JournalKinesisStreamDescription]? = nil) {
            self.nextToken = nextToken
            self.streams = streams
        }

        private enum CodingKeys: String, CodingKey {
            case nextToken = "NextToken"
            case streams = "Streams"
        }
    }

    public struct ListJournalS3ExportsForLedgerRequest: AWSEncodableShape {
        /// The maximum number of results to return in a single ListJournalS3ExportsForLedger request. (The actual number of results returned might be fewer.)
        public let maxResults: Int?
        /// The name of the ledger.
        public let name: String
        /// A pagination token, indicating that you want to retrieve the next page of results. If you received a value for NextToken in the response from a previous ListJournalS3ExportsForLedger call, then you should use that value as input here.
        public let nextToken: String?

        @inlinable
        public init(maxResults: Int? = nil, name: String, nextToken: String? = nil) {
            self.maxResults = maxResults
            self.name = name
            self.nextToken = nextToken
        }

        public func encode(to encoder: Encoder) throws {
            let request = encoder.userInfo[.awsRequest]! as! RequestEncodingContainer
            _ = encoder.container(keyedBy: CodingKeys.self)
            request.encodeQuery(self.maxResults, key: "max_results")
            request.encodePath(self.name, key: "Name")
            request.encodeQuery(self.nextToken, key: "next_token")
        }

        public func validate(name: String) throws {
            try self.validate(self.maxResults, name: "maxResults", parent: name, max: 100)
            try self.validate(self.maxResults, name: "maxResults", parent: name, min: 1)
            try self.validate(self.name, name: "name", parent: name, max: 32)
            try self.validate(self.name, name: "name", parent: name, min: 1)
            try self.validate(self.name, name: "name", parent: name, pattern: "^(?!^.*--)(?!^[0-9]+$)(?!^-)(?!.*-$)^[A-Za-z0-9-]+$")
            try self.validate(self.nextToken, name: "nextToken", parent: name, max: 1024)
            try self.validate(self.nextToken, name: "nextToken", parent: name, min: 4)
            try self.validate(self.nextToken, name: "nextToken", parent: name, pattern: "^[A-Za-z-0-9+/=]+$")
        }

        private enum CodingKeys: CodingKey {}
    }

    public struct ListJournalS3ExportsForLedgerResponse: AWSDecodableShape {
        /// The journal export jobs that are currently associated with the specified ledger.
        public let journalS3Exports: [JournalS3ExportDescription]?
        ///   If NextToken is empty, then the last page of results has been processed and there are no more results to be retrieved.   If NextToken is not empty, then there are more results available. To retrieve the next page of results, use the value of NextToken in a subsequent ListJournalS3ExportsForLedger call.
        public let nextToken: String?

        @inlinable
        public init(journalS3Exports: [JournalS3ExportDescription]? = nil, nextToken: String? = nil) {
            self.journalS3Exports = journalS3Exports
            self.nextToken = nextToken
        }

        private enum CodingKeys: String, CodingKey {
            case journalS3Exports = "JournalS3Exports"
            case nextToken = "NextToken"
        }
    }

    public struct ListJournalS3ExportsRequest: AWSEncodableShape {
        /// The maximum number of results to return in a single ListJournalS3Exports request. (The actual number of results returned might be fewer.)
        public let maxResults: Int?
        /// A pagination token, indicating that you want to retrieve the next page of results. If you received a value for NextToken in the response from a previous ListJournalS3Exports call, then you should use that value as input here.
        public let nextToken: String?

        @inlinable
        public init(maxResults: Int? = nil, nextToken: String? = nil) {
            self.maxResults = maxResults
            self.nextToken = nextToken
        }

        public func encode(to encoder: Encoder) throws {
            let request = encoder.userInfo[.awsRequest]! as! RequestEncodingContainer
            _ = encoder.container(keyedBy: CodingKeys.self)
            request.encodeQuery(self.maxResults, key: "max_results")
            request.encodeQuery(self.nextToken, key: "next_token")
        }

        public func validate(name: String) throws {
            try self.validate(self.maxResults, name: "maxResults", parent: name, max: 100)
            try self.validate(self.maxResults, name: "maxResults", parent: name, min: 1)
            try self.validate(self.nextToken, name: "nextToken", parent: name, max: 1024)
            try self.validate(self.nextToken, name: "nextToken", parent: name, min: 4)
            try self.validate(self.nextToken, name: "nextToken", parent: name, pattern: "^[A-Za-z-0-9+/=]+$")
        }

        private enum CodingKeys: CodingKey {}
    }

    public struct ListJournalS3ExportsResponse: AWSDecodableShape {
        /// The journal export jobs for all ledgers that are associated with the current Amazon Web Services account and Region.
        public let journalS3Exports: [JournalS3ExportDescription]?
        ///   If NextToken is empty, then the last page of results has been processed and there are no more results to be retrieved.   If NextToken is not empty, then there are more results available. To retrieve the next page of results, use the value of NextToken in a subsequent ListJournalS3Exports call.
        public let nextToken: String?

        @inlinable
        public init(journalS3Exports: [JournalS3ExportDescription]? = nil, nextToken: String? = nil) {
            self.journalS3Exports = journalS3Exports
            self.nextToken = nextToken
        }

        private enum CodingKeys: String, CodingKey {
            case journalS3Exports = "JournalS3Exports"
            case nextToken = "NextToken"
        }
    }

    public struct ListLedgersRequest: AWSEncodableShape {
        /// The maximum number of results to return in a single ListLedgers request. (The actual number of results returned might be fewer.)
        public let maxResults: Int?
        /// A pagination token, indicating that you want to retrieve the next page of results. If you received a value for NextToken in the response from a previous ListLedgers call, then you should use that value as input here.
        public let nextToken: String?

        @inlinable
        public init(maxResults: Int? = nil, nextToken: String? = nil) {
            self.maxResults = maxResults
            self.nextToken = nextToken
        }

        public func encode(to encoder: Encoder) throws {
            let request = encoder.userInfo[.awsRequest]! as! RequestEncodingContainer
            _ = encoder.container(keyedBy: CodingKeys.self)
            request.encodeQuery(self.maxResults, key: "max_results")
            request.encodeQuery(self.nextToken, key: "next_token")
        }

        public func validate(name: String) throws {
            try self.validate(self.maxResults, name: "maxResults", parent: name, max: 100)
            try self.validate(self.maxResults, name: "maxResults", parent: name, min: 1)
            try self.validate(self.nextToken, name: "nextToken", parent: name, max: 1024)
            try self.validate(self.nextToken, name: "nextToken", parent: name, min: 4)
            try self.validate(self.nextToken, name: "nextToken", parent: name, pattern: "^[A-Za-z-0-9+/=]+$")
        }

        private enum CodingKeys: CodingKey {}
    }

    public struct ListLedgersResponse: AWSDecodableShape {
        /// The ledgers that are associated with the current Amazon Web Services account and Region.
        public let ledgers: [LedgerSummary]?
        /// A pagination token, indicating whether there are more results available:   If NextToken is empty, then the last page of results has been processed and there are no more results to be retrieved.   If NextToken is not empty, then there are more results available. To retrieve the next page of results, use the value of NextToken in a subsequent ListLedgers call.
        public let nextToken: String?

        @inlinable
        public init(ledgers: [LedgerSummary]? = nil, nextToken: String? = nil) {
            self.ledgers = ledgers
            self.nextToken = nextToken
        }

        private enum CodingKeys: String, CodingKey {
            case ledgers = "Ledgers"
            case nextToken = "NextToken"
        }
    }

    public struct ListTagsForResourceRequest: AWSEncodableShape {
        /// The Amazon Resource Name (ARN) for which to list the tags. For example:  arn:aws:qldb:us-east-1:123456789012:ledger/exampleLedger
        public let resourceArn: String

        @inlinable
        public init(resourceArn: String) {
            self.resourceArn = resourceArn
        }

        public func encode(to encoder: Encoder) throws {
            let request = encoder.userInfo[.awsRequest]! as! RequestEncodingContainer
            _ = encoder.container(keyedBy: CodingKeys.self)
            request.encodePath(self.resourceArn, key: "ResourceArn")
        }

        public func validate(name: String) throws {
            try self.validate(self.resourceArn, name: "resourceArn", parent: name, max: 1600)
            try self.validate(self.resourceArn, name: "resourceArn", parent: name, min: 20)
        }

        private enum CodingKeys: CodingKey {}
    }

    public struct ListTagsForResourceResponse: AWSDecodableShape {
        /// The tags that are currently associated with the specified Amazon QLDB resource.
        public let tags: [String: String]?

        @inlinable
        public init(tags: [String: String]? = nil) {
            self.tags = tags
        }

        private enum CodingKeys: String, CodingKey {
            case tags = "Tags"
        }
    }

    public struct ResourceAlreadyExistsException: AWSErrorShape {
        public let message: String?
        /// The name of the resource.
        public let resourceName: String?
        /// The type of resource.
        public let resourceType: String?

        @inlinable
        public init(message: String? = nil, resourceName: String? = nil, resourceType: String? = nil) {
            self.message = message
            self.resourceName = resourceName
            self.resourceType = resourceType
        }

        private enum CodingKeys: String, CodingKey {
            case message = "Message"
            case resourceName = "ResourceName"
            case resourceType = "ResourceType"
        }
    }

    public struct ResourceInUseException: AWSErrorShape {
        public let message: String?
        /// The name of the resource.
        public let resourceName: String?
        /// The type of resource.
        public let resourceType: String?

        @inlinable
        public init(message: String? = nil, resourceName: String? = nil, resourceType: String? = nil) {
            self.message = message
            self.resourceName = resourceName
            self.resourceType = resourceType
        }

        private enum CodingKeys: String, CodingKey {
            case message = "Message"
            case resourceName = "ResourceName"
            case resourceType = "ResourceType"
        }
    }

    public struct ResourceNotFoundException: AWSErrorShape {
        public let message: String?
        /// The name of the resource.
        public let resourceName: String?
        /// The type of resource.
        public let resourceType: String?

        @inlinable
        public init(message: String? = nil, resourceName: String? = nil, resourceType: String? = nil) {
            self.message = message
            self.resourceName = resourceName
            self.resourceType = resourceType
        }

        private enum CodingKeys: String, CodingKey {
            case message = "Message"
            case resourceName = "ResourceName"
            case resourceType = "ResourceType"
        }
    }

    public struct ResourcePreconditionNotMetException: AWSErrorShape {
        public let message: String?
        /// The name of the resource.
        public let resourceName: String?
        /// The type of resource.
        public let resourceType: String?

        @inlinable
        public init(message: String? = nil, resourceName: String? = nil, resourceType: String? = nil) {
            self.message = message
            self.resourceName = resourceName
            self.resourceType = resourceType
        }

        private enum CodingKeys: String, CodingKey {
            case message = "Message"
            case resourceName = "ResourceName"
            case resourceType = "ResourceType"
        }
    }

    public struct S3EncryptionConfiguration: AWSEncodableShape & AWSDecodableShape {
        /// The Amazon Resource Name (ARN) of a symmetric encryption key in Key Management Service (KMS). Amazon S3 does not support asymmetric KMS keys. You must provide a KmsKeyArn if you specify SSE_KMS as the ObjectEncryptionType.  KmsKeyArn is not required if you specify SSE_S3 as the ObjectEncryptionType.
        public let kmsKeyArn: String?
        /// The Amazon S3 object encryption type. To learn more about server-side encryption options in Amazon S3, see Protecting Data Using Server-Side Encryption in the Amazon S3 Developer Guide.
        public let objectEncryptionType: S3ObjectEncryptionType

        @inlinable
        public init(kmsKeyArn: String? = nil, objectEncryptionType: S3ObjectEncryptionType) {
            self.kmsKeyArn = kmsKeyArn
            self.objectEncryptionType = objectEncryptionType
        }

        public func validate(name: String) throws {
            try self.validate(self.kmsKeyArn, name: "kmsKeyArn", parent: name, max: 1600)
            try self.validate(self.kmsKeyArn, name: "kmsKeyArn", parent: name, min: 20)
        }

        private enum CodingKeys: String, CodingKey {
            case kmsKeyArn = "KmsKeyArn"
            case objectEncryptionType = "ObjectEncryptionType"
        }
    }

    public struct S3ExportConfiguration: AWSEncodableShape & AWSDecodableShape {
        /// The Amazon S3 bucket name in which a journal export job writes the journal contents. The bucket name must comply with the Amazon S3 bucket naming conventions. For more information, see Bucket Restrictions and Limitations in the Amazon S3 Developer Guide.
        public let bucket: String
        /// The encryption settings that are used by a journal export job to write data in an Amazon S3 bucket.
        public let encryptionConfiguration: S3EncryptionConfiguration
        /// The prefix for the Amazon S3 bucket in which a journal export job writes the journal contents. The prefix must comply with Amazon S3 key naming rules and restrictions. For more information, see Object Key and Metadata in the Amazon S3 Developer Guide. The following are examples of valid Prefix values:    JournalExports-ForMyLedger/Testing/     JournalExports     My:Tests/
        public let prefix: String

        @inlinable
        public init(bucket: String, encryptionConfiguration: S3EncryptionConfiguration, prefix: String) {
            self.bucket = bucket
            self.encryptionConfiguration = encryptionConfiguration
            self.prefix = prefix
        }

        public func validate(name: String) throws {
            try self.validate(self.bucket, name: "bucket", parent: name, max: 255)
            try self.validate(self.bucket, name: "bucket", parent: name, min: 3)
            try self.validate(self.bucket, name: "bucket", parent: name, pattern: "^[A-Za-z-0-9-_.]+$")
            try self.encryptionConfiguration.validate(name: "\(name).encryptionConfiguration")
            try self.validate(self.prefix, name: "prefix", parent: name, max: 128)
        }

        private enum CodingKeys: String, CodingKey {
            case bucket = "Bucket"
            case encryptionConfiguration = "EncryptionConfiguration"
            case prefix = "Prefix"
        }
    }

    public struct StreamJournalToKinesisRequest: AWSEncodableShape {
        /// The exclusive date and time that specifies when the stream ends. If you don't define this parameter, the stream runs indefinitely until you cancel it. The ExclusiveEndTime must be in ISO 8601 date and time format and in Universal Coordinated Time (UTC). For example: 2019-06-13T21:36:34Z.
        public let exclusiveEndTime: Date?
        /// The inclusive start date and time from which to start streaming journal data. This parameter must be in ISO 8601 date and time format and in Universal Coordinated Time (UTC). For example: 2019-06-13T21:36:34Z. The InclusiveStartTime cannot be in the future and must be before ExclusiveEndTime. If you provide an InclusiveStartTime that is before the ledger's CreationDateTime, QLDB effectively defaults it to the ledger's CreationDateTime.
        public let inclusiveStartTime: Date
        /// The configuration settings of the Kinesis Data Streams destination for your stream request.
        public let kinesisConfiguration: KinesisConfiguration
        /// The name of the ledger.
        public let ledgerName: String
        /// The Amazon Resource Name (ARN) of the IAM role that grants QLDB permissions for a journal stream to write data records to a Kinesis Data Streams resource. To pass a role to QLDB when requesting a journal stream, you must have permissions to perform the iam:PassRole action on the IAM role resource. This is required for all journal stream requests.
        public let roleArn: String
        /// The name that you want to assign to the QLDB journal stream. User-defined names can help identify and indicate the purpose of a stream. Your stream name must be unique among other active streams for a given ledger. Stream names have the same naming constraints as ledger names, as defined in Quotas in Amazon QLDB in the Amazon QLDB Developer Guide.
        public let streamName: String
        /// The key-value pairs to add as tags to the stream that you want to create. Tag keys are case sensitive. Tag values are case sensitive and can be null.
        public let tags: [String: String]?

        @inlinable
        public init(exclusiveEndTime: Date? = nil, inclusiveStartTime: Date, kinesisConfiguration: KinesisConfiguration, ledgerName: String, roleArn: String, streamName: String, tags: [String: String]? = nil) {
            self.exclusiveEndTime = exclusiveEndTime
            self.inclusiveStartTime = inclusiveStartTime
            self.kinesisConfiguration = kinesisConfiguration
            self.ledgerName = ledgerName
            self.roleArn = roleArn
            self.streamName = streamName
            self.tags = tags
        }

        public func encode(to encoder: Encoder) throws {
            let request = encoder.userInfo[.awsRequest]! as! RequestEncodingContainer
            var container = encoder.container(keyedBy: CodingKeys.self)
            try container.encodeIfPresent(self.exclusiveEndTime, forKey: .exclusiveEndTime)
            try container.encode(self.inclusiveStartTime, forKey: .inclusiveStartTime)
            try container.encode(self.kinesisConfiguration, forKey: .kinesisConfiguration)
            request.encodePath(self.ledgerName, key: "LedgerName")
            try container.encode(self.roleArn, forKey: .roleArn)
            try container.encode(self.streamName, forKey: .streamName)
            try container.encodeIfPresent(self.tags, forKey: .tags)
        }

        public func validate(name: String) throws {
            try self.kinesisConfiguration.validate(name: "\(name).kinesisConfiguration")
            try self.validate(self.ledgerName, name: "ledgerName", parent: name, max: 32)
            try self.validate(self.ledgerName, name: "ledgerName", parent: name, min: 1)
            try self.validate(self.ledgerName, name: "ledgerName", parent: name, pattern: "^(?!^.*--)(?!^[0-9]+$)(?!^-)(?!.*-$)^[A-Za-z0-9-]+$")
            try self.validate(self.roleArn, name: "roleArn", parent: name, max: 1600)
            try self.validate(self.roleArn, name: "roleArn", parent: name, min: 20)
            try self.validate(self.streamName, name: "streamName", parent: name, max: 32)
            try self.validate(self.streamName, name: "streamName", parent: name, min: 1)
            try self.validate(self.streamName, name: "streamName", parent: name, pattern: "^(?!^.*--)(?!^[0-9]+$)(?!^-)(?!.*-$)^[A-Za-z0-9-]+$")
            try self.tags?.forEach {
                try validate($0.key, name: "tags.key", parent: name, max: 128)
                try validate($0.key, name: "tags.key", parent: name, min: 1)
                try validate($0.value, name: "tags[\"\($0.key)\"]", parent: name, max: 256)
            }
            try self.validate(self.tags, name: "tags", parent: name, max: 200)
        }

        private enum CodingKeys: String, CodingKey {
            case exclusiveEndTime = "ExclusiveEndTime"
            case inclusiveStartTime = "InclusiveStartTime"
            case kinesisConfiguration = "KinesisConfiguration"
            case roleArn = "RoleArn"
            case streamName = "StreamName"
            case tags = "Tags"
        }
    }

    public struct StreamJournalToKinesisResponse: AWSDecodableShape {
        /// The UUID (represented in Base62-encoded text) that QLDB assigns to each QLDB journal stream.
        public let streamId: String?

        @inlinable
        public init(streamId: String? = nil) {
            self.streamId = streamId
        }

        private enum CodingKeys: String, CodingKey {
            case streamId = "StreamId"
        }
    }

    public struct TagResourceRequest: AWSEncodableShape {
        /// The Amazon Resource Name (ARN) to which you want to add the tags. For example:  arn:aws:qldb:us-east-1:123456789012:ledger/exampleLedger
        public let resourceArn: String
        /// The key-value pairs to add as tags to the specified QLDB resource. Tag keys are case sensitive. If you specify a key that already exists for the resource, your request fails and returns an error. Tag values are case sensitive and can be null.
        public let tags: [String: String]

        @inlinable
        public init(resourceArn: String, tags: [String: String]) {
            self.resourceArn = resourceArn
            self.tags = tags
        }

        public func encode(to encoder: Encoder) throws {
            let request = encoder.userInfo[.awsRequest]! as! RequestEncodingContainer
            var container = encoder.container(keyedBy: CodingKeys.self)
            request.encodePath(self.resourceArn, key: "ResourceArn")
            try container.encode(self.tags, forKey: .tags)
        }

        public func validate(name: String) throws {
            try self.validate(self.resourceArn, name: "resourceArn", parent: name, max: 1600)
            try self.validate(self.resourceArn, name: "resourceArn", parent: name, min: 20)
            try self.tags.forEach {
                try validate($0.key, name: "tags.key", parent: name, max: 128)
                try validate($0.key, name: "tags.key", parent: name, min: 1)
                try validate($0.value, name: "tags[\"\($0.key)\"]", parent: name, max: 256)
            }
            try self.validate(self.tags, name: "tags", parent: name, max: 200)
        }

        private enum CodingKeys: String, CodingKey {
            case tags = "Tags"
        }
    }

    public struct TagResourceResponse: AWSDecodableShape {
        public init() {}
    }

    public struct UntagResourceRequest: AWSEncodableShape {
        /// The Amazon Resource Name (ARN) from which to remove the tags. For example:  arn:aws:qldb:us-east-1:123456789012:ledger/exampleLedger
        public let resourceArn: String
        /// The list of tag keys to remove.
        public let tagKeys: [String]

        @inlinable
        public init(resourceArn: String, tagKeys: [String]) {
            self.resourceArn = resourceArn
            self.tagKeys = tagKeys
        }

        public func encode(to encoder: Encoder) throws {
            let request = encoder.userInfo[.awsRequest]! as! RequestEncodingContainer
            _ = encoder.container(keyedBy: CodingKeys.self)
            request.encodePath(self.resourceArn, key: "ResourceArn")
            request.encodeQuery(self.tagKeys, key: "tagKeys")
        }

        public func validate(name: String) throws {
            try self.validate(self.resourceArn, name: "resourceArn", parent: name, max: 1600)
            try self.validate(self.resourceArn, name: "resourceArn", parent: name, min: 20)
            try self.tagKeys.forEach {
                try validate($0, name: "tagKeys[]", parent: name, max: 128)
                try validate($0, name: "tagKeys[]", parent: name, min: 1)
            }
            try self.validate(self.tagKeys, name: "tagKeys", parent: name, max: 200)
        }

        private enum CodingKeys: CodingKey {}
    }

    public struct UntagResourceResponse: AWSDecodableShape {
        public init() {}
    }

    public struct UpdateLedgerPermissionsModeRequest: AWSEncodableShape {
        /// The name of the ledger.
        public let name: String
        /// The permissions mode to assign to the ledger. This parameter can have one of the following values:    ALLOW_ALL: A legacy permissions mode that enables access control with API-level granularity for ledgers. This mode allows users who have the SendCommand API permission for this ledger to run all PartiQL commands (hence, ALLOW_ALL) on any tables in the specified ledger. This mode disregards any table-level or command-level IAM permissions policies that you create for the ledger.    STANDARD: (Recommended) A permissions mode that enables access control with finer granularity for ledgers, tables, and PartiQL commands. By default, this mode denies all user requests to run any PartiQL commands on any tables in this ledger. To allow PartiQL commands to run, you must create IAM permissions policies for specific table resources and PartiQL actions, in addition to the SendCommand API permission for the ledger. For information, see Getting started with the standard permissions mode in the Amazon QLDB Developer Guide.    We strongly recommend using the STANDARD permissions mode to maximize the security of your ledger data.
        public let permissionsMode: PermissionsMode

        @inlinable
        public init(name: String, permissionsMode: PermissionsMode) {
            self.name = name
            self.permissionsMode = permissionsMode
        }

        public func encode(to encoder: Encoder) throws {
            let request = encoder.userInfo[.awsRequest]! as! RequestEncodingContainer
            var container = encoder.container(keyedBy: CodingKeys.self)
            request.encodePath(self.name, key: "Name")
            try container.encode(self.permissionsMode, forKey: .permissionsMode)
        }

        public func validate(name: String) throws {
            try self.validate(self.name, name: "name", parent: name, max: 32)
            try self.validate(self.name, name: "name", parent: name, min: 1)
            try self.validate(self.name, name: "name", parent: name, pattern: "^(?!^.*--)(?!^[0-9]+$)(?!^-)(?!.*-$)^[A-Za-z0-9-]+$")
        }

        private enum CodingKeys: String, CodingKey {
            case permissionsMode = "PermissionsMode"
        }
    }

    public struct UpdateLedgerPermissionsModeResponse: AWSDecodableShape {
        /// The Amazon Resource Name (ARN) for the ledger.
        public let arn: String?
        /// The name of the ledger.
        public let name: String?
        /// The current permissions mode of the ledger.
        public let permissionsMode: PermissionsMode?

        @inlinable
        public init(arn: String? = nil, name: String? = nil, permissionsMode: PermissionsMode? = nil) {
            self.arn = arn
            self.name = name
            self.permissionsMode = permissionsMode
        }

        private enum CodingKeys: String, CodingKey {
            case arn = "Arn"
            case name = "Name"
            case permissionsMode = "PermissionsMode"
        }
    }

    public struct UpdateLedgerRequest: AWSEncodableShape {
        /// Specifies whether the ledger is protected from being deleted by any user. If not defined during ledger creation, this feature is enabled (true) by default. If deletion protection is enabled, you must first disable it before you can delete the ledger. You can disable it by calling the UpdateLedger operation to set this parameter to false.
        public let deletionProtection: Bool?
        /// The key in Key Management Service (KMS) to use for encryption of data at rest in the ledger. For more information, see Encryption at rest in the Amazon QLDB Developer Guide. Use one of the following options to specify this parameter:    AWS_OWNED_KMS_KEY: Use an KMS key that is owned and managed by Amazon Web Services on your behalf.    Undefined: Make no changes to the KMS key of the ledger.    A valid symmetric customer managed KMS key: Use the specified symmetric encryption KMS key in your account that you create, own, and manage. Amazon QLDB does not support asymmetric keys. For more information, see Using symmetric and asymmetric keys in the Key Management Service Developer Guide.   To specify a customer managed KMS key, you can use its key ID, Amazon Resource Name (ARN), alias name, or alias ARN. When using an alias name, prefix it with "alias/". To specify a key in a different Amazon Web Services account, you must use the key ARN or alias ARN. For example:   Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab    Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab    Alias name: alias/ExampleAlias    Alias ARN: arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias    For more information, see Key identifiers (KeyId) in the Key Management Service Developer Guide.
        public let kmsKey: String?
        /// The name of the ledger.
        public let name: String

        @inlinable
        public init(deletionProtection: Bool? = nil, kmsKey: String? = nil, name: String) {
            self.deletionProtection = deletionProtection
            self.kmsKey = kmsKey
            self.name = name
        }

        public func encode(to encoder: Encoder) throws {
            let request = encoder.userInfo[.awsRequest]! as! RequestEncodingContainer
            var container = encoder.container(keyedBy: CodingKeys.self)
            try container.encodeIfPresent(self.deletionProtection, forKey: .deletionProtection)
            try container.encodeIfPresent(self.kmsKey, forKey: .kmsKey)
            request.encodePath(self.name, key: "Name")
        }

        public func validate(name: String) throws {
            try self.validate(self.kmsKey, name: "kmsKey", parent: name, max: 1600)
            try self.validate(self.name, name: "name", parent: name, max: 32)
            try self.validate(self.name, name: "name", parent: name, min: 1)
            try self.validate(self.name, name: "name", parent: name, pattern: "^(?!^.*--)(?!^[0-9]+$)(?!^-)(?!.*-$)^[A-Za-z0-9-]+$")
        }

        private enum CodingKeys: String, CodingKey {
            case deletionProtection = "DeletionProtection"
            case kmsKey = "KmsKey"
        }
    }

    public struct UpdateLedgerResponse: AWSDecodableShape {
        /// The Amazon Resource Name (ARN) for the ledger.
        public let arn: String?
        /// The date and time, in epoch time format, when the ledger was created. (Epoch time format is the number of seconds elapsed since 12:00:00 AM January 1, 1970 UTC.)
        public let creationDateTime: Date?
        /// Specifies whether the ledger is protected from being deleted by any user. If not defined during ledger creation, this feature is enabled (true) by default. If deletion protection is enabled, you must first disable it before you can delete the ledger. You can disable it by calling the UpdateLedger operation to set this parameter to false.
        public let deletionProtection: Bool?
        /// Information about the encryption of data at rest in the ledger. This includes the current status, the KMS key, and when the key became inaccessible (in the case of an error).
        public let encryptionDescription: LedgerEncryptionDescription?
        /// The name of the ledger.
        public let name: String?
        /// The current status of the ledger.
        public let state: LedgerState?

        @inlinable
        public init(arn: String? = nil, creationDateTime: Date? = nil, deletionProtection: Bool? = nil, encryptionDescription: LedgerEncryptionDescription? = nil, name: String? = nil, state: LedgerState? = nil) {
            self.arn = arn
            self.creationDateTime = creationDateTime
            self.deletionProtection = deletionProtection
            self.encryptionDescription = encryptionDescription
            self.name = name
            self.state = state
        }

        private enum CodingKeys: String, CodingKey {
            case arn = "Arn"
            case creationDateTime = "CreationDateTime"
            case deletionProtection = "DeletionProtection"
            case encryptionDescription = "EncryptionDescription"
            case name = "Name"
            case state = "State"
        }
    }

    public struct ValueHolder: AWSEncodableShape & AWSDecodableShape {
        /// An Amazon Ion plaintext value contained in a ValueHolder structure.
        public let ionText: String?

        @inlinable
        public init(ionText: String? = nil) {
            self.ionText = ionText
        }

        public func validate(name: String) throws {
            try self.validate(self.ionText, name: "ionText", parent: name, max: 1048576)
            try self.validate(self.ionText, name: "ionText", parent: name, min: 1)
        }

        private enum CodingKeys: String, CodingKey {
            case ionText = "IonText"
        }
    }
}

// MARK: - Errors

/// Error enum for QLDB
public struct QLDBErrorType: AWSErrorType {
    enum Code: String {
        case invalidParameterException = "InvalidParameterException"
        case limitExceededException = "LimitExceededException"
        case resourceAlreadyExistsException = "ResourceAlreadyExistsException"
        case resourceInUseException = "ResourceInUseException"
        case resourceNotFoundException = "ResourceNotFoundException"
        case resourcePreconditionNotMetException = "ResourcePreconditionNotMetException"
    }

    private let error: Code
    public let context: AWSErrorContext?

    /// initialize QLDB
    public init?(errorCode: String, context: AWSErrorContext) {
        guard let error = Code(rawValue: errorCode) else { return nil }
        self.error = error
        self.context = context
    }

    internal init(_ error: Code) {
        self.error = error
        self.context = nil
    }

    /// return error code string
    public var errorCode: String { self.error.rawValue }

    /// One or more parameters in the request aren't valid.
    public static var invalidParameterException: Self { .init(.invalidParameterException) }
    /// You have reached the limit on the maximum number of resources allowed.
    public static var limitExceededException: Self { .init(.limitExceededException) }
    /// The specified resource already exists.
    public static var resourceAlreadyExistsException: Self { .init(.resourceAlreadyExistsException) }
    /// The specified resource can't be modified at this time.
    public static var resourceInUseException: Self { .init(.resourceInUseException) }
    /// The specified resource doesn't exist.
    public static var resourceNotFoundException: Self { .init(.resourceNotFoundException) }
    /// The operation failed because a condition wasn't satisfied in advance.
    public static var resourcePreconditionNotMetException: Self { .init(.resourcePreconditionNotMetException) }
}

extension QLDBErrorType: AWSServiceErrorType {
    public static let errorCodeMap: [String: AWSErrorShape.Type] = [
        "InvalidParameterException": QLDB.InvalidParameterException.self,
        "LimitExceededException": QLDB.LimitExceededException.self,
        "ResourceAlreadyExistsException": QLDB.ResourceAlreadyExistsException.self,
        "ResourceInUseException": QLDB.ResourceInUseException.self,
        "ResourceNotFoundException": QLDB.ResourceNotFoundException.self,
        "ResourcePreconditionNotMetException": QLDB.ResourcePreconditionNotMetException.self
    ]
}

extension QLDBErrorType: Equatable {
    public static func == (lhs: QLDBErrorType, rhs: QLDBErrorType) -> Bool {
        lhs.error == rhs.error
    }
}

extension QLDBErrorType: CustomStringConvertible {
    public var description: String {
        return "\(self.error.rawValue): \(self.message ?? "")"
    }
}
